<%@ page import="com.hc.commodity.dao.impl.EmpDaoImpl" %>
<%@ page import="com.hc.commodity.pojo.Emp" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/4/9
  Time: 20:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>修改员工信息</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css">
</head>
<body>

    <%
        //获取要修改员工的编号
        String id = request.getParameter("id");
        if (id != null){
            Emp emp = new EmpDaoImpl().findById(Integer.parseInt(id));
            session.setAttribute("emp",emp);
        }

        //获取修改后的员工信息，存入数据库中
        String ename = request.getParameter("ename");
        if (ename != null){
            Emp emp = (Emp) session.getAttribute("emp");
            emp.setEname(ename);
            emp.setJob(request.getParameter("job"));
            emp.setMgr(Integer.parseInt(request.getParameter("mgr")));
            emp.setSal(Double.parseDouble(request.getParameter("sal")));
            emp.setComm(Double.parseDouble(request.getParameter("comm")));
            emp.setDeptno(Integer.parseInt(request.getParameter("deptno")));
            new EmpDaoImpl().updataEmp(emp);
            request.getRequestDispatcher("empManage.jsp").forward(request,response);
        }
    %>
    <div class="container">
        <ul class="breadcrumb">
            <li><a href="#">员工管理系统</a></li>
            <li><a href="empManage.jsp">员工管理</a></li>
            <li><a href="#">修改员工信息</a></li>
        </ul>
        <h3>修改员工信息</h3>
        <form class="form-horizontal" action="empUpdata.jsp" method="post">
            <div class="form-group">
                <label class="col-md-2 control-label col-md-offset-2">员工编号</label>
                <div class="col-md-3">
                    <fieldset disabled>
                        <input type="test" class="form-control" id="disabledInput" placeholder="${emp.empno}">
                    </fieldset>
                </div>
            </div>
            <div class="form-group">
                <label for="ename" class="col-md-2 control-label col-md-offset-2">姓名</label>
                <div class="col-md-3">
                    <input type="test" class="form-control" id="ename" placeholder="${emp.ename}" name="ename">
                </div>
            </div>
            <div class="form-group">
                <label for="job" class="col-md-2 control-label col-md-offset-2">职位</label>
                <div class="col-md-3">
                    <input type="test" class="form-control" id="job" placeholder="${emp.job}" name="job">
                </div>
            </div>
            <div class="form-group">
                <label for="mgr" class="col-md-2 control-label col-md-offset-2">上司</label>
                <div class="col-md-3">
                    <input type="test" class="form-control" id="mgr" placeholder="${emp.mgr}" name="mgr">
                </div>
            </div>
            <div class="form-group">
                <label for="hiredate" class="col-md-2 control-label col-md-offset-2">入职日期</label>
                <div class="col-md-3">
                    <fieldset disabled>
                        <input type="test" class="form-control" id="hiredate" placeholder="${emp.hiredate}">
                    </fieldset>
                </div>
            </div>
            <div class="form-group">
                <label for="sal" class="col-md-2 control-label col-md-offset-2">工资</label>
                <div class="col-md-3">
                    <input type="test" class="form-control" id="sal" placeholder="${emp.sal}" name="sal">
                </div>
            </div>
            <div class="form-group">
                <label for="comm" class="col-md-2 control-label col-md-offset-2">奖金</label>
                <div class="col-md-3">
                    <input type="test" class="form-control" id="comm" placeholder="${emp.comm}" name="comm">
                </div>
            </div>
            <div class="form-group">
                <label for="deptno" class="col-md-2 control-label col-md-offset-2">部门编号</label>
                <div class="col-md-3">
                    <input type="test" class="form-control" id="deptno" placeholder="${emp.deptno}" name="deptno">
                </div>
            </div>
            <div class="form-group">
                <input type="submit" value="确定" class="col-md-offset-5 btn btn-primary">
            </div>
        </form>
    </div>

</body>
</html>
